<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php
/**
 * Customer login form template
 *
 * @see app/design/frontend/base/default/template/customer/form/login.phtml
 */
/** @var $this Mage_Customer_Block_Form_Login */
?>


<div class="account-login">
    <div class="page-title">
        <h1><?php echo $this->__('用户注册') ?></h1>
    </div>
    <?php echo $this->getMessagesBlock()->toHtml() ?>
    <form action="<?php echo $this->getUrl('customer/account/createPost') ?>" method="post" id="login-form" autocomplete="off">
    <input style="display:none" type="text" name="fakeusernameremembered"/>
    <input style="display:none" type="password" name="fakepasswordremembered"/>
        <?php echo $this->getBlockHtml('formkey') ?>

                <div class="content">

                    <ul class="form-list">
                        <li>
                            <div class="input-box input-log input-bor">
                                <label>手机号</label>
                                <input id="validate-phone" placeholder="<?php echo $this->__('手机号') ?>" type="text" name="mobile" value="<?php echo $this->escapeHtml($this->getMobile()) ?>"  class="input-text required-entry" title="<?php echo $this->__('iphone') ?>" autocomplete="off"/>
                            </div>
                        </li>
                        <li>
                            <div class="input-box input-log input-bor">
                                <label>用户名</label>
                                <input id="validate-username" placeholder="<?php echo $this->__('用户名') ?>" type="text" name="firstname" value="<?php echo $this->escapeHtml($this->getFirstname()) ?>"  class="input-text required-entry validate-length minimum-length-2 maximum-length-16" title="<?php echo $this->__('iphone') ?>" autocomplete="off"/>
                            </div>
                        </li>
                        <li>
                            <div class="input-box input-log input-bor">
                                <label>店铺名</label>
                                <input id="validate-storename" placeholder="<?php echo $this->__('店铺名') ?>" type="text" name="lastname" value="<?php echo $this->escapeHtml($this->getLastname()) ?>"  class="input-text required-entry validate-length minimum-length-2 maximum-length-16" title="<?php echo $this->__('iphone') ?>" autocomplete="off"/>
                            </div>
                        </li>
                        <li>
                            <div class="input-box input-log">
                                <label>密码</label>
                                <input id="validate-password" placeholder="<?php echo $this->__('密码') ?>" type="password" name="password" class="input-text required-entry validate-password" id="pass" title="<?php echo $this->__('Password') ?>" autocomplete="off"/>
                            </div>
                        </li>
                        <li>
                            <div class="input-box input-log">
                                <label>确认密码</label>
                                <input id="validate-repassword" placeholder="<?php echo $this->__('确认密码') ?>" type="password" name="confirmation" class="input-text required-entry validate-cpassword" id="pass" title="<?php echo $this->__('Password') ?>" autocomplete="off"/>
                            </div>
                        </li>
                        <li>
                            <div class="input-box input-log">
                                <label>请选择站点</label>
                                <div>
                                    <select id="region"  class="input-text">
                                        <option value="">-请选择-</option>
                                    </select>
                                    <select id="city" style="margin-top:10px" class="input-text">
                                        <option value="">-请选择-</option>
                                    </select></br>
                                    <select id="website_id" style="margin-top:10px" name="website_id" class="required-entry input-text">
                                        <option value="">-请选择-</option>
                                    </select>
                                </div>
                            </div>
                        </li>

                        <?php echo $this->getChildHtml('form.additional.info'); ?>
                        <?php echo $this->getChildHtml('persistent.remember.me'); ?>
                        <!-- Dan Tend Yao Qiu Mei Yong De Yao Qiu Cao -->
                        <li>
                            <div class="input-box input-log">
                                <input id="no-angered" checked="checked" type="radio" name="b" value="0"> 
                                <label style="display: inline-block;">
                                    <a class="agreement-onsent" href="<?php echo Mage::getBaseUrl()?>privacy-policy" target="_blank">同意注册协议</a>
                                </label>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <input id="yes-angered" type="radio" name="b" value="1">
                                <label style="display: inline-block;">不同意注册协议</label>
                            </div>
                        </li>
                    </ul>

                    <?php echo $this->getChildHtml('persistent.remember.me.tooltip'); ?>
                    <div class="bottom">
                        <button  type="submit" title="<?php echo $this->__('注册') ?>" class="button login-btn"  name="send" id="send2"><span><span><?php echo $this->__('注&nbsp;&nbsp;册') ?></span></span></button>
                    </div>
                </div>

        <?php if (Mage::helper('checkout')->isContextCheckout()): ?>
            <input name="context" type="hidden" value="checkout" />
        <?php endif; ?>
    </form>
    <script type="text/javascript">
    //<![CDATA[
    var dataForm = new VarienForm('login-form', false);
    //]]>
    (function($){
        var region = null;
        $(document).ready(function(){
            $("#login-form").submit(function(){
                var phoneReg = /^1[3578]\d{9}$/;
                if(phoneReg.test($("#validate-phone").val()) == false){
                    alert("手机号码格式不正确");
                    return false;
                }

                var username = /^\d+$/;
                if(username.test($("#validate-username").val()))
                {
                    alert("用户名不能使用纯数字！");
                    return false;
                }
            });

            $.getJSON('<?php echo $this->getUrl("api/rest/stores");?>',function(data){
                region = data.data;
                for(var i=0;i<region.region.length;i++)
                {
                    var reg = region.region[i];
                    $("#region").append('<option value="'+reg.id+'">'+reg.name+'</option>');
                }
            });
            $("#region").change(function(){
                $("#city").html('<option value="">-请选择-</option>');
                var val = $(this).val();
                for(var i=0;i<region.city.length;i++)
                {
                    var reg = region.city[i];
                    if(reg.parent_id==val)
                    {
                        $("#city").append('<option value="'+reg.id+'">'+reg.name+'</option>');
                    }
                    
                }
            });
            $("#city").change(function(){
                $("#website_id").html('<option value="">-请选择-</option>');
                var val = $(this).val();
                for(var i=0;i<region.area.length;i++)
                {
                    var reg = region.area[i];
                    if(reg.parent_id==val)
                    {
                        $("#website_id").append('<option value="'+reg.id+'">'+reg.name+'</option>');
                    }
                    
                }
            });
        });

        $('input[type="radio"]').change(function(){
            if($('input[type="radio"]:checked()').val() == 1)
            {
                $('#send2').attr('disabled','disabled');
            }else{
                $('#send2').removeAttr('disabled');
            }
        })
    })(jQuery);
    </script>
</div>




